Skip to content

prototype: api contract test harness#3640

Closed
zackverham wants to merge 8 commits intomainfrom
zverham/api-contract-test-harness
Closed

prototype: api contract test harness#3640
zackverham wants to merge 8 commits intomainfrom
zverham/api-contract-test-harness

Conversation

@zackverham
Copy link
Collaborator

@zackverham zackverham commented Mar 3, 2026

Screenshot 2026-03-03 at 4 13 20 PM

Intent

Type of Change

    • Bug Fix
    • New Feature
    • Breaking Change
    • Documentation
    • Refactor
    • Tooling

Approach

User Impact

Automated Tests

Directions for Reviewers

Checklist

  • I have updated the root CHANGELOG.md to cover notable changes.

zackverham and others added 8 commits March 3, 2026 13:53
Introduce a Vitest-based test suite at test/api-contracts/ that spawns the
real Go binary, makes HTTP requests to API endpoints, and validates response
shapes via snapshot testing. This enables verifying API parity when migrating
the backend from Go to TypeScript.

Initial coverage includes 24 tests across 3 endpoint groups:
- configurations (GET list, GET single, PUT create, DELETE)
- credentials (GET list, POST create, DELETE by GUID, DELETE reset)
- deployments (GET list, GET single, POST create, PATCH update, DELETE)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduce a BackendClient abstraction so the same 24 contract tests and
snapshots can validate both the Go HTTP backend and the future TypeScript
direct-call backend. Tests now call client.getConfigurations() instead
of apiGet("/api/configurations"), with backend selection via API_BACKEND
env var.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use "ok" | "created" | "no_content" | "not_found" | "conflict" instead
of numeric HTTP codes. Drop contentType from ContractResult entirely —
the Go client validates content-type internally. This makes the future
TypeScript direct-call client simpler to implement since it won't need
to produce HTTP-specific values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ehavior

Introduces a test harness that validates both the outbound HTTP requests
Publisher sends to Connect and the correctly parsed responses. This enables
the future TS ConnectClient to be verified against the same contract.

Architecture: test code → Publisher binary → mock Connect server (Node.js).
The mock captures all incoming requests for assertion. Currently implements
TestAuthentication end-to-end (8 tests); CreateDeployment and ContentDetails
are stubbed as describe.skip since they aren't triggerable via standalone
Publisher API endpoints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds mock routes, fixtures, and skipped test files for every method on
the Connect APIClient interface. The mock server now supports non-JSON
responses (HTML, raw bytes, 204 no-body) and has routes ordered by
specificity. All 65 new tests are describe.skip — ready to un-skip
when the TS ConnectClient is implemented.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduces a third contract test suite (test/extension-api-contracts/) that
validates how the extension's Axios client constructs requests to Publisher's
API and parses responses. Uses a mock Publisher server with canned responses
and request capture, following the connect-api-contracts pattern.

79 tests across configurations, credentials, and deployments endpoints verify
request correctness (method, path, query params, headers, body), response
parsing, and response shape stability via snapshots.

Also includes expanded connect-api-contracts test coverage for authentication
edge cases, content details, validate deployment, and wait-for-task endpoints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extends the api-contracts suite with tests for GET /api/entrypoints and
POST /api/inspect endpoints. Adds fixture workspaces for jupyter-nb,
quarto-doc, rmd-static, and shiny-python content types to enable
inspection testing across multiple project types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zackverham
Copy link
Collaborator Author

Splitting into three focused PRs:

@zackverham zackverham closed this Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant